$('.datatable-basic').DataTable({
	 "ajax" : {
		"url" : contextpath + "integrationRule/list",
		"data" : function(d) {
            var query = $("#query").serializeObject();
            query["size"] = d.length;
            query["page"] = (d.start/d.length);
			return query;
		},
		"dataFilter": function(data){
            var json = jQuery.parseJSON( data );
            json.recordsTotal = json.totalElements;
            json.recordsFiltered = json.totalElements;
            json.data = json.content;
 
            return JSON.stringify( json );
        }
	 },
	 "columns": [
         { "data": "ruleCode" },
         { "data": "ruleName" },
         { "data": "integrationD" },
         {
             render : function(data,type, row, meta) {
            	 return $("#btnGroup").html();
             }
         }
     ],
     "drawCallback": function( settings ) {
		 $(".btn-edit").click(function(){
			$("#edit").validate().resetForm();
		    $("#edit").fill($('.datatable-basic').DataTable().row($(this).closest("tr")).data());
		    var row = $('.datatable-basic').DataTable().row($(this).closest("tr")).data();
		    
		    $(":input[name='id']").val(row.id);
		 });
      }
});

$(function(){
	$("#submitEdit").click(function(){
		if($("#edit").valid()){
			$.post(contextpath + "integrationRule/save", $("#edit").serialize(), function(){
				$('.datatable-basic').DataTable().draw();
				$('.close').click();
				swal("编辑积分规则成功","", "success");
			})
		}
	});
	 
	$("#submit").click(function(){
		$('.datatable-basic').DataTable().draw();
	});

})
